package web.blogsphere.config;

import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import web.blogsphere.model.Result;

/**
 * @ClassName ExceptionHandle
 * @Description  统一异常处理
 * @Author ZJX
 * @Date 2024/9/3 20:39
 * @Version 1.0
 */
@Slf4j
@ResponseBody
@ControllerAdvice
public class ExceptionHandle {
    @ExceptionHandler
//    全局捕获异常
    public Result handle(Exception e){
        log.error("发生异常, e:",e);
        return Result.fail("内部错误, 请联系管理员");
    }
}
